package com.elastic.utils;

import org.w3c.dom.Document;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;

import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import java.io.File;

public class XMLUtils {

    public static  Object getBean() throws Exception {
        DocumentBuilderFactory dFactory = DocumentBuilderFactory.newInstance();

        DocumentBuilder documentBuilder = dFactory.newDocumentBuilder();

        Document document = documentBuilder.parse(new File("config.xml"));

        NodeList nodeList = document.getElementsByTagName("className");


        Node node = nodeList.item(0).getFirstChild();

        String nodeValue = node.getNodeValue();

        Class<?> clazz = Class.forName(nodeValue);

        return clazz.newInstance();


    }


}
